<script setup lang="ts">
import { ref, onMounted } from 'vue'
import ScreenTourtist from '@/views/screen/components/ScreenTourtist.vue'
import ScreenAge from '@/views/screen/components/ScreenAge.vue'
import ScreenSex from '@/views/screen/components/ScreenSex.vue'
//获取数据大屏展示内容盒子的DOM元素
//引入顶部的子组件
import Top from './components/ScreenTop.vue'
import ScreenLine from '@/views/screen/components/ScreenLine.vue'
import ScreenMap from '@/views/screen/components/ScreenMap.vue'
import ScreenRank from '@/views/screen/components/ScreenRank.vue'
import ScreenYear from '@/views/screen/components/ScreenYear.vue'
import ScreenCouter from '@/views/screen/components/ScreenCouter.vue'
let screen = ref()
onMounted(() => {
  screen.value.style.transform = `scale(${getScale()}) translate(-50%,-50%)`
})
//定义大屏缩放比例
function getScale(w = 1920, h = 1080) {
  const ww = window.innerWidth / w
  const wh = window.innerHeight / h
  return ww < wh ? ww : wh
}
//监听视口变化
window.onresize = () => {
  if (screen.value) {
    screen.value.style.transform = `scale(${getScale()}) translate(-50%,-50%)`
  }

}
</script>

<template>
  <div class="container">
    <!-- 数据大屏展示内容区域 -->
    <div class="screen" ref="screen">
      <div class="top"><Top /></div>
      <div class="bottom">
        <div class="left">
          <ScreenTourtist class="tourtist" />
          <ScreenSex class="sex" />
          <ScreenAge class="age" />
        </div>
        <div class="center">
          <ScreenMap class="map" />
          <ScreenLine class="line" />
        </div>
        <div class="right">
          <ScreenRank class="rank" />
          <ScreenYear class="year" />
          <ScreenCouter class="couter" />
        </div>
      </div>
    </div>
  </div>
</template>

<style lang="scss" scoped>
.container {
  width: 100vw;
  height: 100vh;
  background: url(./images/bg.png) no-repeat;
  background-size: cover;
  .screen {
    position: fixed;
    width: 1920px;
    height: 1080px;
    left: 50%;
    top: 50%;
    transform-origin: left top;
    .top {
      width: 100%;
      height: 40px;
    }
    .bottom {
      display: flex;
      .right {
        flex: 1;
        display: flex;
        flex-direction: column;
        margin-left: 40px;
        .rank {
          flex: 1.5;
        }

        .year {
          flex: 1;
        }

        .couter {
          flex: 1;
        }
      }
      .left {
        flex: 1;
        height: 1040px;
        display: flex;
        flex-direction: column;
        .tourtist {
          flex: 1.2;
        }
        .sex {
          flex: 1;
        }
        .age {
          flex: 1;
        }
      }
      .center {
        flex: 1.5;
        display: flex;
        flex-direction: column;

        .map {
          flex: 4;
        }
        .line {
          flex: 1;
        }
      }
    }
  }
}
</style>
